package com.wm.prototype;

/**
 * @ClassName: ComputerDetail
 * @Description: 深复制-电脑
 * @Author: WM
 * @Date: 2023/2/9 8:37
 */
public class ComputerDetail implements Cloneable {
    private String cpu;
    private String memory;
    private Disk disk;

    public ComputerDetail(String cpu, String memory, Disk disk) {
        this.cpu = cpu;
        this.memory = memory;
        this.disk = disk;
    }

    @Override
    public ComputerDetail clone() throws CloneNotSupportedException {// 深复制
        ComputerDetail computerDetail = (ComputerDetail) super.clone();
        computerDetail.disk = this.disk.clone();
        return computerDetail;
    }

    @Override
    public String toString() {
        return "ComputerDetail{" +
                "cpu='" + cpu + '\'' +
                ", memory='" + memory + '\'' +
                ", disk=" + disk +
                '}';
    }

    public Disk getDisk() {
        return disk;
    }
}
